home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / 5tinydms / poly1.s < prev    next >
Text File  |  1995-12-05  |  13KB  |  928 lines

  1.  
  2. ********************************************
  3. *                           *
  4. *  Lame generic gouraud routine               *
  5. *  Not optimized at all - Just for sample  *
  6. *  (C)oderight 1995 by Jedi/Sector One     *
  7. *                       *
  8. ********************************************
  9.  
  10. !faraway    set 900
  11.  
  12.     org $100
  13.  
  14. ; flat real mode
  15.  
  16.     d+
  17.     move cs,a
  18.     move a,ds
  19.     move a,es
  20.     add #@stack,a
  21.     move a,ss
  22.     bsr initFRM
  23.  
  24. ; 320x200 / 256
  25.  
  26.     move #$13,a
  27.     trap #$10
  28.  
  29. ;    bsr xmode
  30.  
  31. ; cls
  32.  
  33.     move #$a000,a
  34.     move a,es
  35.     xor a,a
  36.     xor di,di
  37.     move #320*200/2-1,c
  38.     rep:stos
  39.  
  40.     push ds
  41.     push es
  42.  
  43.     xor di,di
  44.     move cs,a
  45.     add #@bkg,a
  46.     move a,es
  47.     move #100,d
  48.     move #160,bp
  49. .loop2    move bp,c
  50.     xor.b a,a
  51.     rep:stos.b
  52.     move.b #128,a
  53.     move bp,c
  54.     rep:stos.b
  55.     dec d
  56.     bne.s .loop2
  57.     move #100,d
  58. .loop2    move bp,c
  59.     move.b #128,a
  60.     rep:stos.b
  61.     xor.b a,a
  62.     move bp,c
  63.     rep:stos.b
  64.     dec d
  65.     bne.s .loop2
  66.  
  67.     pop es
  68.     pop ds
  69.  
  70. ; that's the way I like it
  71.  
  72.     move cs,a
  73.     move a,ds
  74.     move a,es
  75.  
  76. ; Clear the virtual screen
  77.  
  78.     move.l #pchouk,be
  79.     move #[pchoukf-pchouk]/4,c
  80.     xor.l ae,ae
  81. .loop    move.l ae,(be)
  82.     add.l #4,be
  83.     dbf .loop
  84.  
  85. ; Add the bottom border
  86.  
  87.     move.l #pchouk+320*200,be
  88.     move #320,c
  89.     move.b #-1,a
  90. .loop    move.b a,(be)
  91.     inc.l be
  92.     dbf .loop
  93.  
  94. ; Generate a fade table
  95.  
  96.     move.l #fadetable+5,be
  97.     move #251,c
  98.     xor.b a,a
  99.     move.b a,-1(be)
  100.     move.b a,-2(be)
  101.     move.b a,-3(be)
  102.     move.b a,-4(be)
  103.     move.b a,-5(be)
  104. .loop    move.b a,(be)
  105.     inc.b a
  106.     inc.l be
  107.     dbf .loop
  108.  
  109. ; Some great colors
  110.  
  111.     move #$3c8,d
  112.     xor.b a,a
  113.     out.b a,d
  114.     inc d
  115.     move.b #8,b
  116.     move #64,c
  117.     move c,bp
  118.     sub #8,c
  119. .loop    xor.b a,a
  120.     out.b a,d
  121.     out.b a,d
  122.     move.b b,a
  123.     out.b a,d
  124.     inc.b b
  125.     dbf .loop
  126.     move bp,c
  127.     xor.b b,b
  128. .loop    xor.b a,a
  129.     out.b a,d
  130.     move.b b,a
  131.     out.b a,d
  132.     inc.b b
  133.     move.b #63,a
  134.     out.b a,d
  135.     dbf .loop
  136.     move #8,c
  137.     xor.b a,a
  138. .loop    move.b b,a
  139.     out.b a,d
  140.     move.b #63,a
  141.     out.b a,d
  142.     out.b a,d
  143.     add.b #4,b
  144.     dbf .loop
  145.  
  146.     move bp,c
  147.     sub #8,c
  148.     move.b #8,b
  149. .loop    move.b b,a
  150.     out.b a,d
  151.     xor.b a,a
  152.     out.b a,d
  153.     move.b b,a
  154.     out.b a,d
  155.     inc.b b
  156.     dbf .loop
  157.     move bp,c
  158.     xor.b b,b
  159. .loop    move.b #63,a
  160.     out.b a,d
  161.     move.b b,a
  162.     out.b a,d
  163.     inc.b b
  164.     move.b #63,a
  165.     out.b a,d
  166.     dbf .loop
  167.     move #8,c
  168. .loop    move.b #63,a
  169.     out.b a,d
  170.     out.b a,d
  171.     out.b a,d
  172.     dbf .loop
  173.  
  174.  
  175. ; Initialize the 320* table
  176.  
  177.     move.l #multable,be
  178.     move #240,c
  179.     xor a,a
  180. .loop    move a,(be)
  181.     add #320,a
  182.     add.l #2,be
  183.     dbf .loop
  184.  
  185. ; Self-generate the vertical display routine
  186.  
  187.     move.l #realdraw,be
  188.     move #240,c
  189.     xor a,a
  190. .loop
  191.     move #$a788,(be)    ; move.b ah, ...
  192. ;    move #$a700,(be)    ; add.b ah, ...
  193. ;    move #$a708,(be)    ; or.b ah, ...
  194. ;    move #$a710,(be)    ; addx.b ah, ...
  195. ;    move #$a720,(be)    ; and.b ah, ...
  196. ;    move #$a730,(be)    ; xor.b ah, ...
  197.  
  198.     move a,2(be)        ; offset(b)
  199.     move #$c503,4(be)    ; add bp,a
  200.     add.l #6,be
  201.     add #320,a
  202.     dbf .loop
  203.  
  204. ; test polygon
  205.  
  206.     intoff
  207.  
  208. zeloop
  209.     bsr fade
  210. ;    bsr cpybck
  211.  
  212. happy1    move.l #0.l,ae
  213. happy2    move.l #10.l,be
  214. happy3    move.l #30.l,ce
  215.  
  216.     bsr initrotation
  217.  
  218.     inc happy1+2
  219.     and #511,happy1+2
  220.     inc happy2+2
  221.     and #511,happy2+2
  222.     add #3,happy3+2
  223.     and #511,happy3+2
  224.  
  225. ; Process objects
  226.  
  227.     move.l #object,sie
  228. pipi    move.l #points+2,die
  229.     move (sie),bp
  230.     test bp,bp
  231.     beq foune
  232.     move bp,-2(die)
  233.     add.l #2,sie
  234. .loop    move #160,rotatedx
  235.     move #100,rotatedy
  236.     move.l #sintable,be
  237.     xor.l ae,ae
  238.     move 6(sie),a
  239.     add #2,a
  240.     and #511,a
  241.     move a,6(sie)
  242.     move.l (be,ae*4),ae
  243.     asr.l #12-6,ae
  244.     add #64,a
  245.     move a,4(die)
  246.     movesx.l (sie),be
  247.     movesx.l 2(sie),ce
  248.     movesx.l 4(sie),de
  249.     push bp
  250.     push.l sie
  251.     move.l #!faraway,sie
  252.     bsr rotate
  253.     pop.l sie
  254.     pop bp
  255.     move rotatedx,a
  256.     move a,(die)
  257.     move rotatedy,a
  258.     move a,2(die)
  259.     add.l #8,sie
  260.     add.l #6,die
  261.     dec bp
  262.     bne.s .loop
  263.     move.l #points,be
  264.     bsr poly
  265.     bra pipi
  266. foune
  267.  
  268. ; Draw
  269.  
  270. ;    move #$3c8,d
  271. ;    xor.b a,a
  272. ;    out.b a,d
  273. ;    inc d
  274. ;    out.b a,d
  275. ;    out.b a,d
  276. ;    move.b #$31,a
  277. ;    out.b a,d
  278.  
  279. ;    bsr vsync
  280.     bsr cpyscrn
  281.  
  282. ;    move #$3c8,d
  283. ;    xor.b a,a
  284. ;    out.b a,d
  285. ;    inc d
  286. ;    out.b a,d
  287. ;    out.b a,d
  288. ;    out.b a,d
  289.  
  290. * Press [Escape] to logout !
  291.  
  292.         in.b #$60,a
  293.         cmp.b #129,a
  294.         bne zeloop
  295.  
  296.     bsr txtmode
  297.  
  298.     inton
  299.     move #$4c00,a
  300.     trap #$21
  301.  
  302. ; kassos
  303.  
  304.     rts
  305.  
  306. ; be : points addresses
  307.  
  308. poly    pusha.l
  309.     xor.l ae,ae
  310.     move (be),a        ; a : first element of the list
  311.     add.l #2,be
  312.     move.l be,!fone1
  313.     move.l be,!lone2
  314.  
  315.     add a,a
  316.     move a,bp
  317.     add bp,bp
  318.     add bp,a        ; *6 -> a : enda the list
  319.     add.l be,ae
  320.     sub.l #6,ae
  321.     move.l ae,!lone1
  322.     move.l ae,!fone2
  323.  
  324.     move -2(be),c
  325.  
  326.     move (be),bp        ; xmin = first
  327.     move.l be,sie        ; addrmin = first addr
  328. sort    move (be),a        ; x
  329.     cmp bp,a
  330.     bge.s poaplupti        ; zob
  331.     move a,bp        ; new xmin
  332.     move.l be,sie        ; new addy
  333. poaplupti
  334.     add.l #6,be
  335.     dbf sort        ; end of the sort loop. si = lefter item
  336.  
  337.     move.l sie,leftitem
  338.  
  339. ; Compute the first upper item
  340.  
  341.     move.l sie,bpe
  342.     bsr getnextitem
  343.     move.l sie,upitem
  344.  
  345. ; Compute the first lower item
  346.  
  347.     move.l bpe,sie
  348.     bsr getpreviousitem
  349.     move.l sie,downitem
  350.  
  351. ; Compute the left addy
  352.  
  353.     move.l leftitem,de
  354.     xor.l be,be
  355.     move 2(de),b
  356.     xor.l ae,ae
  357.     move (de),a
  358. ;    add.l #$a0000,ae
  359.     move.l ae,leftaddr
  360.  
  361. ; Compute and store the upper slope
  362.  
  363.     move.l leftitem,sie
  364.     move.l upitem,die
  365.     bsr getslope
  366.     move bp,upperslope
  367.     move a,uppershadeslope
  368.  
  369. ; Compute and store the lower slope
  370.  
  371.     move.l leftitem,sie
  372.     move.l downitem,die
  373.     bsr getslope
  374.     move bp,lowerslope
  375.     move a,lowershadeslope
  376.  
  377. ; Init uppery and lowery
  378.  
  379.     move.l leftitem,sie
  380.     move 2(sie),a
  381.     asl #8,a
  382.     move a,uppery
  383.     move a,lowery
  384.  
  385. ; Init uppershade and lowershade
  386.  
  387.     move 4(sie),a
  388.     asl #8,a
  389.     move a,uppershade
  390.     move a,lowershade
  391.  
  392. ; Get the horizontally shorter item
  393.  
  394.     move #0,alreadydone
  395.  
  396. snacker
  397.     move.l upitem,ae
  398.     move (ae),d
  399.     move.l downitem,ae
  400.     move (ae),b
  401.     move d,c        ; up first by default
  402.     move.b #0,dsk
  403.     cmp b,d
  404.     ble.s upfirst
  405.     move b,c
  406.     move.b #1,dsk
  407. upfirst    move.l leftitem,ae
  408.     sub (ae),c        ; c = width of the current segment
  409.     move.l #alreadydone,be
  410.     sub (be),c
  411.     add c,(be)
  412.  
  413. ; Draw the bizness
  414.  
  415.     xor a,a
  416.     move a,gs
  417.  
  418.     test c,c
  419.     ble.s breakit
  420.  
  421. .loop    move.l #multable,sie
  422.     move.l curaddr,be
  423.     move uppery,a
  424.     xor.l de,de
  425.     move.b ah,d
  426.     move d,staxy
  427.     move (sie,de*2),d
  428.     add.l de,be
  429.     move.l be,segmentup
  430.  
  431.     move.l curaddr,be
  432.     move lowery,a
  433.     xor.l de,de
  434.     move.b ah,d
  435.     move d,staxy2
  436.     move (sie,de*2),d
  437.     add.l de,be
  438.     move.l be,segmentdown
  439.  
  440.     bsr drawsegment
  441.     inc.l curaddr
  442.  
  443. breakit    move upperslope,a
  444.     add a,uppery
  445.     move lowerslope,a
  446.     add a,lowery
  447.     move uppershadeslope,a
  448.     add a,uppershade
  449.     move lowershadeslope,a
  450.     add a,lowershade
  451.     dec c
  452.     bgt .loop
  453.  
  454. ; If both segments converged to the same point, then the polygon is completed
  455.  
  456.     move.l upitem,a
  457.     cmp.l downitem,a
  458.     beq yoopikassos
  459.  
  460. ; Next point
  461.  
  462.     move.b dsk,a
  463.     test.b a,a        ; 0 = up
  464.     bne downstairs
  465.  
  466. ; Snap the upper part
  467.  
  468.     move.l upitem,sie
  469.     push.l sie
  470.     bsr getnextitem
  471.     move.l sie,upitem
  472.     move.l sie,ae
  473.  
  474.     pop.l sie
  475.     move.l ae,die
  476.     bsr getslope
  477.     move bp,upperslope
  478.     move a,uppershadeslope
  479.  
  480.     bra snacker
  481.  
  482. downstairs
  483.  
  484.     move.l downitem,sie
  485.     push.l sie
  486.     bsr getpreviousitem
  487.     move.l sie,downitem
  488.     move.l sie,ae
  489.  
  490.     pop.l sie
  491.     move.l ae,die
  492.     bsr getslope
  493.     move bp,lowerslope
  494.     move a,lowershadeslope
  495.  
  496.     bra snacker
  497.  
  498. yoopikassos
  499.     popa.l
  500.     rts
  501.  
  502. ; Draw a gouraud segment
  503.  
  504. drawsegment
  505.  
  506.     pusha.l
  507.  
  508.     xor.l ce,ce
  509.     move staxy2,c
  510.     sub staxy,c
  511.     ble.s topdelire
  512. xtazy
  513.     move.l segmentup,be
  514.  
  515.     move.l ce,bpe
  516.     move lowershade,a
  517.     sub uppershade,a
  518.     beq.s pipe
  519.     ext.l
  520.     ext.q
  521.     idiv.l bpe
  522. pipe
  523.     move a,bp
  524.     move uppershade,a
  525.  
  526.     add c,c
  527.     move c,d
  528.     add c,c
  529.     add d,c            ; *6
  530.     move.l #realdraw+4,sie
  531.     add.l ce,sie
  532.     move.b (sie),c
  533.     move.b #$c3,(sie)    ; Move the 'rts'
  534.     push ds
  535.     move cs,d
  536.     add #@pchouk,d
  537. ;    move #$a000,d
  538.     move d,ds
  539.     bsr realdraw
  540.     pop ds
  541.  
  542.     move.b c,(sie)
  543.  
  544. topdelire
  545.     popa.l
  546.     rts
  547.  
  548. ; Various datas
  549.  
  550.     align.l
  551. leftitem
  552.     dc.l 0
  553. upitem    dc.l 0
  554. downitem
  555.     dc.l 0
  556. curaddr
  557. leftaddr
  558.     dc.l 0
  559. segmentup
  560.     dc.l 0
  561. segmentdown
  562.     dc.l 0
  563. upperslope
  564.     dc.w 0
  565. lowerslope
  566.     dc.w 0
  567. uppery    dc.w 0
  568. lowery    dc.w 0
  569. dsk    dc.w 0
  570. alreadydone
  571.     dc.w 0
  572. staxy    dc.w 0
  573. staxy2    dc.w 0
  574. uppershadeslope
  575.     dc.w 0
  576. lowershadeslope
  577.     dc.w 0
  578. uppershade
  579.     dc.w 0
  580. lowershade
  581.     dc.w 0
  582.  
  583. ; Get the left xtrem of a segment in (sie), the right one in (die),
  584. ; computes the slope and returns it in bp
  585. ; The shading step is also computed and returns in ae
  586.  
  587. getslope
  588.     move 2(die),a
  589.     sub 2(sie),a
  590.     ext.l
  591.     ext.q
  592.     asl.l #8,ae
  593.     xor.l be,be
  594.     move (die),b
  595.     sub (sie),b
  596.     beq.s exitslp
  597.     idiv.l be        ; ae# = (y2#-y1#)/(x2#-x1#)
  598. exitslp
  599.     move a,bp
  600. onslp
  601.  
  602. ; Compute the shading
  603.  
  604.     move 4(die),a
  605.     sub 4(sie),a
  606.     ext.l
  607.     ext.q
  608.     asl.l #8,ae
  609.     xor.l be,be
  610.     move (die),b
  611.     sub (sie),b
  612.     beq.s exitslp2
  613.     idiv.l be        ; ae# = (s2#-s1#)/(x2#-x1#)
  614.  
  615. exitslp2
  616.     rts
  617.  
  618. ; Takes sie, find the previous item and put it anew to sie
  619.  
  620. getpreviousitem
  621.  
  622. .tmp    cmp.l #'ideJ',sie    ; first one ?
  623. !fone1    set .tmp+3
  624.     bne.s nomod1
  625. .tmp    move.l #'ideJ',sie    ; -> last one
  626. !lone1    set .tmp+2
  627.     bra.s endmod1
  628. nomod1    sub.l #6,sie        ; previous one
  629. endmod1
  630.     rts
  631.  
  632. ; Take sie, find the next item and put it anew to sie
  633.  
  634. getnextitem
  635.  
  636. .tmp    cmp.l #'ideJ',sie    ; last one ?
  637. !fone2    set .tmp+3
  638.     bne.s nomod2
  639. .tmp    move.l #'ideJ',sie    ; -> first one
  640. !lone2    set .tmp+2
  641.     bra.s endmod2
  642. nomod2    add.l #6,sie        ; next one
  643. endmod2
  644.     rts
  645.  
  646.     include frm.si
  647.  
  648. ; Sample objects. Format is :
  649. ; - number of points
  650. ; - x, y, lightshade
  651. ; .points are ignored
  652.  
  653. object
  654.     dc.w 4
  655.     dc.w -64,64,-64,0+16
  656.     dc.w -64,-64,-64,90+16
  657.     dc.w 64,-64,-64,180+16
  658.     dc.w 64,64,-64,270+16
  659.  
  660.     dc.w 4
  661.     dc.w -64,64,64,71+16
  662.     dc.w -64,-64,64,250+16
  663.     dc.w -64,-64,-64,90+16
  664.     dc.w -64,64,-64,0+16
  665.  
  666.     dc.w 4
  667.     dc.w 64,64,-64,270+16
  668.     dc.w 64,-64,-64,180+16
  669.     dc.w 64,-64,64,90+16
  670.     dc.w 64,64,64,30+16
  671.  
  672.     dc.w 4
  673.     dc.w -64,-64,-64,90+16
  674.     dc.w -64,-64,64,250+16
  675.     dc.w 64,-64,64,90+16
  676.     dc.w 64,-64,-64,180+16
  677.  
  678.     dc.w 4
  679.     dc.w -64,64,64,71+16
  680.     dc.w -64,64,-64,0+16
  681.     dc.w 64,64,-64,270+16
  682.     dc.w 64,64,64,30+16
  683.  
  684.     dc.w 0
  685.  
  686. points    dc.w 0
  687.     dc.w 0,0,0
  688.     dc.w 0,0,0
  689.     dc.w 0,0,0
  690.     dc.w 0,0,0
  691.  
  692. ; Sinus tables
  693.  
  694.     align.l
  695. sintable
  696.     incbin sintable.sct
  697. .costable    set sintable+128*4
  698.  
  699.     align.l
  700.  
  701. rots1    dc.l 0
  702. rotc1    dc.l 0
  703. rots2    dc.l 0
  704. rotc2    dc.l 0
  705. rots3    dc.l 0
  706. rotc3    dc.l 0
  707. rotj    dc.l 0
  708. rotk    dc.l 0
  709. rotl    dc.l 0
  710. rotm    dc.l 0
  711. rotd    dc.l 0
  712. rotg    dc.l 0
  713. rote    dc.l 0
  714. roth    dc.l 0
  715. rota    dc.l 0
  716. rotb    dc.l 0
  717.  
  718. rotatedx
  719.     dc.l 0
  720. rotatedy
  721.     dc.l 0
  722.  
  723. ; 3D Rotations - Initialize the vectorial base
  724. ; ae = xrot   be = yrot   ce = zrot
  725.  
  726. initrotation
  727.     move.l #sintable,sie
  728.     move.l #.costable,die
  729.     move.l (sie,ae*4),de
  730.     move.l de,rots1
  731.     move.l (die,ae*4),de
  732.     move.l de,rotc1
  733.     move.l (sie,be*4),de
  734.     move.l de,rots2
  735.     move.l (die,be*4),de
  736.     move.l de,rotc2
  737.     move.l (sie,ce*4),de
  738.     move.l de,rots3
  739.     move.l (die,ce*4),de
  740.     move.l de,rotc3
  741.  
  742.     move.l rots3,be
  743.     move.l rotc1,ae
  744.     move.l ae,ce        ; c = c1
  745.     imul.l be,ae
  746.     asr.l #12,ae
  747.     move.l ae,rotj
  748.  
  749.     move.l rots1,ae
  750.     move.l ae,bpe        ; bp = s1
  751.     imul.l be,ae
  752.     asr.l #12,ae
  753.     move.l ae,rotk
  754.  
  755.     move.l rotc3,de
  756.     move.l ce,ae
  757.     imul.l de,ae
  758.     asr.l #12,ae
  759.     move.l ae,rotl
  760.  
  761.     move.l bpe,ae
  762.     imul.l de,ae
  763.     asr.l #12,ae
  764.     move.l ae,rotm
  765.  
  766.     move.l rots2,be        ; b = s2
  767.     imul.l be,ae        ; a = m*s2
  768.     asr.l #12,ae
  769.     sub.l rotj,ae
  770.     move.l ae,rotd
  771.  
  772.     move.l rotl,ae
  773.     move.l ae,bpe        ; bp = l
  774.     imul.l be,ae        ; a = l*s2
  775.     asr.l #12,ae
  776.     move.l rotk,ce        ; c = k
  777.     add.l ce,ae
  778.     move.l ae,rotg
  779.  
  780.     move.l ce,ae
  781.     imul.l be,ae
  782.     asr.l #12,ae
  783.     add.l bpe,ae
  784.     move.l ae,rote
  785.  
  786.     move.l rotj,ae
  787.     imul.l be,ae
  788.     asr.l #12,ae
  789.     sub.l rotm,ae
  790.     move.l ae,roth
  791.  
  792.     move.l rotc2,be        ; b = c2
  793.     move.l rotc3,ae
  794.     imul.l be,ae
  795.     asr.l #12,ae
  796.     move.l ae,rota
  797.  
  798.     move.l rots3,ae
  799.     imul.l be,ae
  800.     asr.l #12,ae
  801.     move.l ae,rotb
  802.  
  803.     rts
  804.  
  805. ; According to the previously calculated vectorial base, project
  806. ; a 3D couple of points on the 2D screen plane
  807. ; be = x   ce = y   de = z   sie = zdep
  808. ; Results addad to (rotatedx) and (rotatedy)
  809.  
  810. rotate
  811.     move.l rota,bpe
  812.     imul.l be,bpe
  813.     move.l rotd,ae
  814.     imul.l ce,ae
  815.     add.l ae,bpe
  816.     move.l rotg,ae
  817.     imul.l de,ae
  818.     add.l ae,bpe
  819.     move.l sie,ae
  820.     imul.l bpe,ae
  821.     asr.l #12+10,ae
  822.     add.l ae,rotatedx
  823.  
  824.     move.l rotb,bpe
  825.     imul.l be,bpe
  826.     move.l rote,ae
  827.     imul.l ce,ae
  828.     add.l ae,bpe
  829.     move.l roth,ae
  830.     imul.l de,ae
  831.     add.l ae,bpe
  832.     move.l sie,ae
  833.     imul.l bpe,ae
  834.     asr.l #12+10,ae
  835.     add.l ae,rotatedy
  836.  
  837.     rts
  838.  
  839. cpybck
  840.     push ds
  841.     push es
  842.  
  843.     move cs,a
  844.     add #@pchouk,a
  845.     move a,es
  846.     move cs,a
  847.     add #@bkg,a
  848.     move a,ds
  849.     xor si,si
  850.     xor di,di
  851.     move #320*200/4,c
  852.     rep:moves.l
  853.  
  854.     pop es
  855.     pop ds
  856.  
  857.     rts
  858.  
  859. fade
  860.     push ds
  861.     push es
  862.  
  863.     move cs,a
  864.     add #@pchouk,a
  865.     move a,ds
  866.     xor b,b
  867.     assume pchouk
  868.     move.l #fadetable,sie
  869.     assume START
  870.  
  871.     move #320*200,c
  872.     xor.l ae,ae
  873. .loop    move.b 320(b),a
  874.     move.b (sie,ae),a
  875.     move.b a,(b)
  876.     inc b
  877.     dec c
  878.     bne.s .loop
  879.  
  880.     pop es
  881.     pop ds
  882.  
  883.     rts
  884.  
  885. cpyscrn
  886.     push ds
  887.     push es
  888.  
  889.     move #$a000,a
  890.     move a,es
  891.     move cs,a
  892.     add #@pchouk,a
  893.     move a,ds
  894.     xor si,si
  895.     xor di,di
  896.     move #320*200/2,c
  897.     rep:moves.w
  898.  
  899.     pop es
  900.     pop ds
  901.  
  902.     rts
  903.  
  904.     include xymode.si
  905.  
  906.     section bss
  907.  
  908. ; Self-generated code to draw a vertical shaded line
  909.  
  910. realdraw
  911.     ds.w 6*240/2        ; Generated at the beginning of the code
  912.     rts            ; Just for fun and security
  913.  
  914. multable
  915.     ds.w 240        ; 240 in case of a 320x240 resolution
  916.  
  917.     segment
  918. pchouk    ds.l 320*240/4
  919. pchoukf
  920.     align.l
  921. fadetable
  922.     ds.b 256
  923.     segment
  924. bkg    ds.l 320*240/4
  925.     segment
  926.     ds.l 512
  927. stack
  928.